package com.zeta.demo.es.model.enums;

import cn.hutool.core.util.EnumUtil;

/**
 * 搜索类型 枚举
 *
 * @author gcc
 */
public enum SearchTypeEnum {
    /** 分词搜索 */
    WORD_SEARCH(0),
    /** 精确搜索 */
    EXACT_SEARCH(1),
    ;

    private final Integer code;

    SearchTypeEnum(Integer code) {
        this.code = code;
    }

    public Integer getCode() {
        return code;
    }

    /**
     * 根据code获取枚举
     *
     * @param code 枚举的code值
     * @return 枚举
     */
    public static SearchTypeEnum getByCode(Integer code) {
        if (code == null) { return null; }
        return EnumUtil.getBy(SearchTypeEnum::getCode, code);
    }

}
